import '@tarojs/async-await'
import Taro, { Component } from '@tarojs/taro'
import { Provider } from '@tarojs/redux'
import zoro from '@opcjs/zoro'
import counter from './models/counter' // 引入counter model
//引入taro UI样式
import 'taro-ui/dist/style/index.scss'
import Index from './pages/index'

import './app.less'

// 通过zoro创建store，移除原有的代码
const app = zoro()
app.model(counter)
const store = app.start(false)

class App extends Component {
  config = {
    pages: [
      'pages/index/index',
      'pages/modules/index',
      'pages/me/index',
      'pages/warehouse/index'
    ],
    window: {
      backgroundTextStyle: 'light',
      navigationBarBackgroundColor: '#fff',
      navigationBarTitleText: 'WeChat',
      navigationBarTextStyle: 'black'
    },
    tabBar: {
      color: "#666",
      selectedColor: "#b4282d",
      backgroundColor: "#fafafa",
      borderStyle: 'black',
      list: [{
        pagePath: "pages/index/index",
        iconPath: "./asstes/tab-bar/home.png",
        selectedIconPath: "./asstes/tab-bar/home-active.png",
        text: "首页"
      }, {
        pagePath: "pages/modules/index",
        iconPath: "./asstes/tab-bar/cate.png",
        selectedIconPath: "./asstes/tab-bar/cate-active.png",
        text: "分类"
      }, {
        pagePath: "pages/me/index",
        iconPath: "./asstes/tab-bar/user.png",
        selectedIconPath: "./asstes/tab-bar/user-active.png",
        text: "个人"
      }]
    }
  }

  componentDidMount () {
    // 手动触发setup
      app.setup()
  }

  render () {
    return (
      <Provider store={store}>
        <Index />
      </Provider>
    )
  }
}

Taro.render(<App />, document.getElementById('app'))